package com.andnnl.db;

import cn.hutool.db.Db;
import cn.hutool.db.Entity;
import cn.hutool.db.ds.DSFactory;

import javax.sql.DataSource;
import java.sql.SQLException;

/**
 * Created by chenss on 2020/5/7.
 */
public class DBMasterSlaveTest {
    public static void main(String[] args) throws SQLException {
        System.out.println(1800 + 50*22 +100);
        doMaster();
        doSlave();

    }

    private static void doMaster() throws SQLException {
        DataSource ds = DSFactory.get("group_db1");
        Entity result =Db.use(ds).queryOne("select @@servername");
        System.out.println(result);
    }

    private static void doSlave() throws SQLException {
        DataSource ds = DSFactory.get("group_db2");
        Entity result =Db.use(ds).queryOne("select @@servername");
        System.out.println(result);
    }
}
